package com.letoken.platform.pub.enums;

import com.baomidou.mybatisplus.annotation.EnumValue;
import com.fasterxml.jackson.annotation.JsonValue;

import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;

/**
 * @author wyl
 * 代币操作-定义枚举
 */
public enum TokenApprovedStateEnum {

//    审批状态(0待审批 1通过 2拒绝)
    /**
     * 代币操作-定义枚举
     */
    PENDING(0 ,"待审批"),
    ADOPT(1, "通过"),
    REFUSE(2, "拒绝"),
    ;


    @EnumValue
    private Integer value;
    @JsonValue
    private String text;

    private static Map<String, TokenApprovedStateEnum> pool = new HashMap<>();


    TokenApprovedStateEnum(Integer value, String text) {
        this.value = value;
        this.text = text;
    }

    public static TokenApprovedStateEnum valueOf(int value) {
        return pool.get(String.valueOf(value));
    }

    public Integer getValue() {
        return this.value;
    }

    public String getText() {
        return text;
    }

    public static boolean isSupport(String val) {
        for (TokenApprovedStateEnum openState : values()) {
            if (openState.getValue().equals(val)) {
                return true;
            }
        }
        return false;
    }

    public static String getText(String val) {
        for (TokenApprovedStateEnum openState : values()) {
            if (openState.getValue().equals(val)) {
                return openState.getText();
            }
        }
        return "";
    }


    public static TokenApprovedStateEnum getInstance(Integer value){
        for (TokenApprovedStateEnum stateEnum : TokenApprovedStateEnum.values()){
            if (stateEnum.getValue().equals(value)){
                return stateEnum;
            }
        }

        return null;

    }


}
